package com.dcrzl.gazgmh.common.utils;

import com.alibaba.fastjson.JSONObject;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

import java.util.Objects;

@Slf4j
public class UserInfoByTokenUtils {
    public static JSONObject parseJson(HttpServletRequest request) {
        log.info(request.getHeader("userToken"));
        log.info(request.getHeader("token"));
        if (StringUtils.hasText(request.getHeader("userToken"))&& !Objects.equals(request.getHeader("userToken"),"null")
                && StringUtils.hasText(request.getHeader("token"))&&!Objects.equals(request.getHeader("token"),"null")) {
            return JSONObject.parseObject(EncryptionUtil.getDecryptDESData(request.getHeader("userToken"), request.getHeader("token")));
        } else {
            return new JSONObject();
        }
    }
}
